#if !SERVER
using UnityEngine;

namespace ActorSystem
{
    public class ActorView : MonoBehaviour
    {
        public ActorBase Actor;

        public T ActorOf<T>() where T : ActorBase
        {
            return Actor as T;
        }

        internal void Start()
        {
            if (Actor is IActorStart)
                Actor.OnStart();
        }

        internal void OnEnable()
        {
            if (Actor is IActorEnable actor)
                actor.OnEnable();
        }

        internal void OnDisable()
        {
            if (Actor is IActorDisable actor)
                actor.OnDisable();
        }

        internal void OnTriggerEnter(Collider other)
        {
            if (Actor is IActorOnTriggerEnter actor)
                actor.OnTriggerEnter(other);
        }

        internal void OnTriggerExit(Collider other)
        {
            if (Actor is IActorOnTriggerExit actor)
                actor.OnTriggerExit(other);
        }

        internal void OnCollisionEnter(Collision collision)
        {
            if (Actor is IActorOnCollisionEnter actor)
                actor.OnCollisionEnter(collision);
        }

        internal void OnCollisionExit(Collision collision)
        {
            if (Actor is IActorOnCollisionExit actor)
                actor.OnCollisionExit(collision);
        }
    }
}
#endif